package com.skit.ecm.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.skit.mine.fragment.PersonFragment

/**
 * @author shuike [Contact me.](mailto:shuike007@gmail.com)
 * @version 1.0
 * @since 2020/4/27
 */
class HomeViewPagerAdapter : FragmentStateAdapter {
    private lateinit var fragments: ArrayList<Fragment>

    constructor(fragments: ArrayList<Fragment>, fragmentActivity: FragmentActivity) : super(
        fragmentActivity
    ) {
        this.fragments = fragments;
    }

    constructor(fragment: Fragment) : super(fragment) {}
    constructor(
        fragmentManager: FragmentManager,
        lifecycle: Lifecycle
    ) : super(fragmentManager, lifecycle) {
    }

    override fun createFragment(position: Int): Fragment {
        return fragments[position]
    }

    override fun getItemCount(): Int {
        return fragments.size
    }
}